<%--
  Created by IntelliJ IDEA.
  User: 杨娇
  Date: 2025/7/3
  Time: 9:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>绿能充 - 公告详情</title>
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <style>
        :root {
            --primary-color: #00a896;
            --secondary-color: #02c39a;
            --dark-color: #05668d;
            --light-color: #f0f3bd;
            --accent-color: #028090;
            --text-dark: #333;
            --text-light: #f8f9fa;
            --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
            --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Noto Sans SC', sans-serif;
            color: var(--text-dark);
            background-color: #f9f9f9;
            min-height: 100vh;
            display: flex;
        }

        /* 侧边栏样式 */
        .sidebar {
            width: 250px;
            background: linear-gradient(135deg, var(--dark-color) 0%, var(--primary-color) 100%);
            color: white;
            padding: 20px 0;
            height: 100vh;
            position: fixed;
            box-shadow: var(--shadow);
            z-index: 100;
        }

        .sidebar-header {
            padding: 0 20px 20px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
            margin-bottom: 20px;
        }

        .sidebar-header .logo {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
        }

        .sidebar-header .logo-icon {
            width: 40px;
            height: 40px;
            background-color: rgba(255, 255, 255, 0.2);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 10px;
            font-size: 18px;
            color: var(--light-color);
        }

        .sidebar-header h3 {
            font-size: 1.2rem;
            font-weight: 500;
            margin: 0;
        }

        .sidebar-header p {
            font-size: 0.8rem;
            opacity: 0.8;
            margin: 0;
        }

        .nav-menu {
            list-style: none;
            padding: 0 15px;
        }

        .nav-item {
            margin-bottom: 5px;
        }

        .nav-link {
            display: flex;
            align-items: center;
            padding: 12px 15px;
            color: rgba(255, 255, 255, 0.8);
            text-decoration: none;
            border-radius: 8px;
            transition: var(--transition);
        }

        .nav-link:hover, .nav-link.active {
            background-color: rgba(255, 255, 255, 0.1);
            color: white;
        }

        .nav-link i {
            margin-right: 10px;
            width: 20px;
            text-align: center;
            font-size: 16px;
        }

        .nav-link .badge {
            margin-left: auto;
            background-color: var(--light-color);
            color: var(--dark-color);
            font-size: 0.7rem;
            padding: 3px 6px;
        }

        .user-profile {
            position: absolute;
            bottom: 20px;
            left: 0;
            width: 100%;
            padding: 0 20px;
        }

        .user-info {
            display: flex;
            align-items: center;
            padding: 10px;
            background-color: rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            cursor: pointer;
            transition: var(--transition);
        }

        .user-info:hover {
            background-color: rgba(255, 255, 255, 0.2);
        }

        .user-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background-color: rgba(255, 255, 255, 0.2);
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 10px;
            font-size: 14px;
        }

        .user-name {
            font-size: 0.9rem;
            font-weight: 500;
            margin-bottom: 2px;
        }

        .user-role {
            font-size: 0.7rem;
            opacity: 0.8;
        }

        /* 主内容区样式 */
        .main-content {
            flex: 1;
            margin-left: 250px;
            padding: 30px;
        }

        .header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 30px;
        }

        .page-title h1 {
            font-size: 1.8rem;
            font-weight: 600;
            color: var(--dark-color);
            margin-bottom: 5px;
        }

        .page-title p {
            color: #777;
            font-size: 0.9rem;
            margin: 0;
        }

        .header-actions {
            display: flex;
            gap: 10px;
        }

        .btn {
            padding: 8px 16px;
            border-radius: 8px;
            font-size: 0.9rem;
            font-weight: 500;
            border: none;
            cursor: pointer;
            transition: var(--transition);
            display: flex;
            align-items: center;
        }

        .btn i {
            margin-right: 6px;
        }

        .btn-primary {
            background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
            color: white;
            box-shadow: 0 4px 15px rgba(0, 168, 150, 0.3);
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 20px rgba(0, 168, 150, 0.4);
        }

        .btn-outline {
            background: transparent;
            border: 1px solid #ddd;
            color: #555;
        }

        .btn-outline:hover {
            background-color: #f5f5f5;
        }

        /* 公告详情样式 */
        .announcement-detail-container {
            background-color: white;
            border-radius: 12px;
            padding: 30px;
            box-shadow: var(--shadow);
        }

        .announcement-header {
            margin-bottom: 30px;
            border-bottom: 1px solid #f0f0f0;
            padding-bottom: 20px;
        }

        .announcement-title {
            font-size: 1.8rem;
            font-weight: 600;
            color: var(--dark-color);
            margin-bottom: 15px;
        }

        .announcement-meta {
            display: flex;
            justify-content: space-between;
            color: #777;
            font-size: 0.9rem;
            margin-bottom: 15px;
        }

        .announcement-tag {
            display: inline-block;
            padding: 4px 10px;
            border-radius: 4px;
            font-size: 0.8rem;
            font-weight: 500;
        }

        .tag-important {
            background-color: #fff3e0;
            color: #e65100;
        }

        .tag-normal {
            background-color: #e3f2fd;
            color: #1976d2;
        }

        .announcement-status {
            font-weight: 500;
        }

        .status-published {
            color: #4caf50;
        }

        .status-draft {
            color: #ff9800;
        }

        .status-archived {
            color: #9e9e9e;
        }

        .announcement-content {
            line-height: 1.8;
            color: #555;
            margin-bottom: 30px;
        }

        .announcement-content p {
            margin-bottom: 15px;
        }

        .announcement-footer {
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid #f0f0f0;
        }

        .attachments-title {
            font-size: 1.1rem;
            font-weight: 500;
            margin-bottom: 15px;
            color: var(--dark-color);
        }

        .attachment-list {
            list-style: none;
        }

        .attachment-item {
            display: flex;
            align-items: center;
            margin-bottom: 10px;
            padding: 10px;
            border-radius: 8px;
            background-color: #f9f9f9;
            transition: var(--transition);
        }

        .attachment-item:hover {
            background-color: #f0f0f0;
        }

        .attachment-icon {
            width: 40px;
            height: 40px;
            border-radius: 8px;
            background-color: var(--light-color);
            display: flex;
            align-items: center;
            justify-content: center;
            margin-right: 15px;
            color: var(--primary-color);
            font-size: 18px;
        }

        .attachment-info {
            flex: 1;
        }

        .attachment-name {
            font-weight: 500;
            margin-bottom: 3px;
        }

        .attachment-size {
            font-size: 0.8rem;
            color: #777;
        }

        .attachment-download {
            padding: 6px 12px;
            background-color: var(--primary-color);
            color: white;
            border-radius: 6px;
            text-decoration: none;
            font-size: 0.9rem;
            transition: var(--transition);
        }

        .attachment-download:hover {
            background-color: var(--accent-color);
        }

        .back-button {
            display: inline-block;
            padding: 10px 20px;
            background-color: #f0f0f0;
            color: #555;
            border-radius: 8px;
            text-decoration: none;
            font-weight: 500;
            transition: var(--transition);
        }

        .back-button:hover {
            background-color: #e0e0e0;
        }

        /* 响应式设计 */
        @media (max-width: 992px) {
            .sidebar {
                width: 70px;
                overflow: hidden;
            }

            .sidebar-header h3,
            .sidebar-header p,
            .nav-link span,
            .user-name,
            .user-role {
                display: none;
            }

            .sidebar-header {
                padding: 15px 10px;
            }

            .nav-link {
                justify-content: center;
                padding: 12px 0;
            }

            .nav-link i {
                margin-right: 0;
                font-size: 18px;
            }

            .main-content {
                margin-left: 70px;
            }
        }

        @media (max-width: 768px) {
            .announcement-meta {
                flex-direction: column;
                gap: 10px;
            }

            .announcement-title {
                font-size: 1.5rem;
            }
        }

        @media (max-width: 576px) {
            .main-content {
                padding: 20px 15px;
            }

            .announcement-detail-container {
                padding: 20px;
            }

            .announcement-title {
                font-size: 1.3rem;
            }
        }
    </style>
</head>
<body>
<!-- 侧边导航栏 -->
<div class="sidebar">
    <div class="sidebar-header">
        <div class="logo">
            <div class="logo-icon">
                <i class="fas fa-charging-station"></i>
            </div>
            <div>
                <h3>绿能充</h3>
                <p>用户面板</p>
            </div>
        </div>
    </div>

    <ul class="nav-menu">
        <li class="nav-item">
            <a href="/user/home" class="nav-link">
                <i class="fas fa-tachometer-alt"></i>
                <span>仪表盘</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/user/announcement/list" class="nav-link active">
                <i class="fas fa-users"></i>
                <span>公告栏</span>
                <span class="badge">5</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/user/pile/list" class="nav-link">
                <i class="fas fa-charging-station"></i>
                <span>充电桩</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/user/map/mapDetail" class="nav-link">
                <i class="fas fa-list-alt"></i>
                <span>地图</span>
            </a>
        </li>
        <li class="nav-item">
            <a href="/user/center/personCenter/${user.id}" class="nav-link">
                <i class="fas fa-exclamation-triangle"></i>
                <span>个人中心</span>
                <span class="badge">3</span>
            </a>
        </li>
    </ul>
    <div class="user-profile">
        <div class="user-info">
            <div class="user-avatar">
                <i class="fas fa-user"></i>
            </div>
            <div>
                <div class="user-name">${user.username}</div>
                <div class="user-role">
                    <c:choose>
                        <c:when test="${user.role == 1}">管理员</c:when>
                        <c:when test="${user.role == 2}">测试员</c:when>
                        <c:otherwise>普通用户</c:otherwise>
                    </c:choose>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 主内容区 -->
<div class="main-content">
    <div class="header">
        <div class="page-title">
            <h1>公告详情</h1>
            <p>查看公告详细信息</p>
        </div>
        <div class="header-actions">
            <a href="/user/announcement/list" class="btn btn-outline">
                <i class="fas fa-arrow-left"></i> 返回列表
            </a>
        </div>
    </div>

    <!-- 公告详情内容 -->
    <div class="announcement-detail-container">
        <div class="announcement-header">
            <h1 class="announcement-title">${announcement.title}</h1>
            <div class="announcement-meta">
                <div>
                    <span>发布时间: <fmt:formatDate value="${announcement.startTime}" pattern="yyyy-MM-dd HH:mm" /></span>
                    <c:if test="${not empty announcement.endTime}">
                        <span> - <fmt:formatDate value="${announcement.endTime}" pattern="yyyy-MM-dd HH:mm" /></span>
                    </c:if>
                </div>
                <div>
                    <span>发布人: ${announcement.publisherId}</span>
                </div>
            </div>
            <div class="announcement-meta">
                <div>
                    <span class="announcement-tag
                        <c:choose>
                            <c:when test="${announcement.type == 'MAINTENANCE'}">tag-important</c:when>
                            <c:otherwise>tag-normal</c:otherwise>
                        </c:choose>">
                        <c:choose>
                            <c:when test="${announcement.type == 'MAINTENANCE'}">维护公告</c:when>
                            <c:when test="${announcement.type == 'PROMOTION'}">活动公告</c:when>
                            <c:when test="${announcement.type == 'SYSTEM'}">系统公告</c:when>
                            <c:otherwise>普通公告</c:otherwise>
                        </c:choose>
                    </span>
                </div>
                <div>
                    <span class="announcement-status
                        <c:choose>
                            <c:when test="${announcement.status == 'PUBLISHED'}">status-published</c:when>
                            <c:when test="${announcement.status == 'DRAFT'}">status-draft</c:when>
                            <c:otherwise>status-archived</c:otherwise>
                        </c:choose>">
                        <c:choose>
                            <c:when test="${announcement.status == 'PUBLISHED'}">已发布</c:when>
                            <c:when test="${announcement.status == 'DRAFT'}">草稿</c:when>
                            <c:otherwise>已归档</c:otherwise>
                        </c:choose>
                    </span>
                </div>
            </div>
        </div>

        <div class="announcement-content">
            ${announcement.content}
        </div>

        <c:if test="${not empty attachments}">
            <div class="announcement-footer">
                <h3 class="attachments-title">附件</h3>
                <ul class="attachment-list">
                    <c:forEach items="${attachments}" var="attachment">
                        <li class="attachment-item">
                            <div class="attachment-icon">
                                <i class="fas
                                    <c:choose>
                                        <c:when test="${fn:endsWith(attachment.name, '.pdf')}">fa-file-pdf</c:when>
                                        <c:when test="${fn:endsWith(attachment.name, '.doc') || fn:endsWith(attachment.name, '.docx')}">fa-file-word</c:when>
                                        <c:when test="${fn:endsWith(attachment.name, '.xls') || fn:endsWith(attachment.name, '.xlsx')}">fa-file-excel</c:when>
                                        <c:when test="${fn:endsWith(attachment.name, '.ppt') || fn:endsWith(attachment.name, '.pptx')}">fa-file-powerpoint</c:when>
                                        <c:when test="${fn:endsWith(attachment.name, '.zip') || fn:endsWith(attachment.name, '.rar')}">fa-file-archive</c:when>
                                        <c:when test="${fn:endsWith(attachment.name, '.jpg') || fn:endsWith(attachment.name, '.jpeg') || fn:endsWith(attachment.name, '.png') || fn:endsWith(attachment.name, '.gif')}">fa-file-image</c:when>
                                        <c:otherwise>fa-file</c:otherwise>
                                    </c:choose>">
                                </i>
                            </div>
                            <div class="attachment-info">
                                <div class="attachment-name">${attachment.name}</div>
                                <div class="attachment-size">${attachment.size}</div>
                            </div>
                            <a href="${attachment.url}" class="attachment-download" download>
                                <i class="fas fa-download"></i> 下载
                            </a>
                        </li>
                    </c:forEach>
                </ul>
            </div>
        </c:if>

        <div style="margin-top: 30px; text-align: center;">
            <a href="/user/announcement/list" class="back-button">
                <i class="fas fa-arrow-left"></i> 返回公告列表
            </a>
        </div>
    </div>
</div>

<script>
    document.addEventListener('DOMContentLoaded', function() {
        // 可以添加任何需要的JavaScript交互
    });
</script>
</body>
</html>
